package com.xingkeduo.pojo.table;

import com.xingkeduo.util.pojo.base.BaseTable;
import com.xingkeduo.util.pojo.enums.*;
import org.apache.ibatis.type.Alias;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 求职者社会属性类
 * 
 * @author 高杰
 * @time 2018年12月25日 下午5:03:47
 * @description
 */
@Alias("JobseekerSocial")
public class JobseekerSocialTO extends BaseTable<JobseekerSocialTO> {

	private String name;
	private String idCard;
	private String phone;
	private SexEnum sex;
	private Date birth;
	private String ethnic;
	private DegreeEnum degree;
	private YesNoEnum isMarried;
	private String houseHold;
	private HouseHoldTypeEnum houseHoldType;
	private BankEnums bank;
	private String bankCard;

	private JobseekerSocialTO jobseekerSocialTO;

	public JobseekerSocialTO setBank(BankEnums bank){
		this.bank=bank;
		return this;
	}

	public BankEnums getBank(){
		return bank;
	}
	public JobseekerSocialTO setBankCard(String bankCard){
		this.bankCard=bankCard;
		return this;
	}

	public String getBankCard(){
		return bankCard;
	}

	public String getName() {
		return name;
	}

	public JobseekerSocialTO setName(String name) {
		this.name = name;
		return this;
	}

	public String getIdCard() {
		return idCard;
	}

	public JobseekerSocialTO setIdCard(String idCard) {
		this.idCard = idCard;
		return this;
	}

	public JobseekerSocialTO analyzeIdCard(String idCard) throws Throwable {
		this.idCard = idCard;

		String sexStr = idCard.substring(16, 17);
		this.sex = SexEnum.getSex(Integer.parseInt(sexStr) % 2);

		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
		String birthStr = idCard.substring(6, 14);
		this.birth = sdf.parse(birthStr);

		return this;
	}

	public String getPhone() {
		return phone;
	}

	public JobseekerSocialTO setPhone(String phone) {
		this.phone = phone;
		return this;
	}

	public SexEnum getSex() {
		return sex;
	}

	public JobseekerSocialTO setSex(SexEnum sex) {
		this.sex = sex;
		return this;
	}

	public Date getBirth() {
		return birth;
	}

	public JobseekerSocialTO setBirth(Date birth) {
		this.birth = birth;
		return this;
	}

	public String getEthnic() {
		return ethnic;
	}

	public JobseekerSocialTO setEthnic(String ethnic) {
		this.ethnic = ethnic;
		return this;
	}

	public DegreeEnum getDegree() {
		return degree;
	}

	public JobseekerSocialTO setDegree(DegreeEnum degree) {
		this.degree = degree;
		return this;
	}

	public YesNoEnum getIsMarried() {
		return isMarried;
	}

	public JobseekerSocialTO setIsMarried(YesNoEnum isMarried) {
		this.isMarried = isMarried;
		return this;
	}

	public String getHouseHold() {
		return houseHold;
	}

	public JobseekerSocialTO setHouseHold(String houseHold) {
		this.houseHold = houseHold;
		return this;
	}

	public HouseHoldTypeEnum getHouseHoldType() {
		return houseHoldType;
	}

	public JobseekerSocialTO setHouseHoldType(HouseHoldTypeEnum houseHoldType) {
		this.houseHoldType = houseHoldType;
		return this;
	}

	public JobseekerSocialTO copy(CraftsmanSocialTO craftsmanSocial) {
		return this.setIdCard(craftsmanSocial.getIdCard()).setPhone(craftsmanSocial.getPhone())
				.setSex(craftsmanSocial.getSex()).setBirth(craftsmanSocial.getBirth())
				.setEthnic(craftsmanSocial.getEthnic()).setDegree(craftsmanSocial.getDegree())
				.setIsMarried(craftsmanSocial.getIsMarried()).setHouseHold(craftsmanSocial.getHouseHold())
				.setHouseHoldType(craftsmanSocial.getHouseHoldType()).setName(craftsmanSocial.getName());
	}
}
